<?php
   
class API_Clients extends API_Class {
                    
    public static $table = 'clients',
                  $viewPlatNums = 'numbers_stats',
                  $viewPlatMoney = 'draft_view';
    
    public function getClientWhere($where){
        $q = "select * from ".self::$table." where ".$where;
        $ret = self::$db->fetchRow($q);
        if(!$ret)return array();
        return $ret; //API_Utils::ansi_to_utf($ret);
    }
    
    public function getClientByAcc($acc){
        return self::getClientWhere("ACCOUNT_NUMBER = '$acc'");
    }
    
    public function normAcc($acc){
        return ereg_replace("[^0-9]", "", $acc);
    }
    
    public function getPlatNums($acc){
        $q = "select * from ".self::$viewPlatNums./*" where client_id = (select client_id from ".self::$table.*/" where ACCOUNT_NUMBER='$acc'";
        $ret = self::$db->fetchAll($q);
        if(!$ret)return array();
        return $ret; //API_Utils::ansi_to_utf($ret);        
    }
    
    public function getPlatMoney($acc){
        $q = "select * from ".self::$viewPlatMoney./*" where client_id = (select client_id from ".self::$table.*/" where ACCOUNT_NUMBER='$acc'";
        $ret = self::$db->fetchRow($q);
        if(!$ret)return array();
        return $ret; //API_Utils::ansi_to_utf($ret);        
    }
    
}